<template>
  <el-menu
    class="categories"
    default-active="0"
    @select="handleSelect"
    active-text-color="#409EFF">
    <el-menu-item index="0">
      <i class="el-icon-menu"></i>
      <span slot="title">全部</span>
    </el-menu-item>
    <el-menu-item index="1">
      <i class="el-icon-menu"></i>
      <span slot="title">情感</span>
    </el-menu-item>
    <el-menu-item index="2">
      <i class="el-icon-menu"></i>
      <span slot="title">幽默</span>
    </el-menu-item>
    <el-menu-item index="3">
      <i class="el-icon-menu"></i>
      <span slot="title">生活</span>
    </el-menu-item>
    <el-menu-item index="4">
      <i class="el-icon-menu"></i>
      <span slot="title">青春</span>
    </el-menu-item>
    <el-menu-item index="5">
      <i class="el-icon-menu"></i>
      <span slot="title">哲理</span>
    </el-menu-item>
    <el-menu-item index="6">
      <i class="el-icon-menu"></i>
      <span slot="title">科技</span>
    </el-menu-item>
  </el-menu>
</template>

<script>
  export default {
    name: 'SideMenu',
    data() {
      return {
        cid: ''
      }
    },
    methods: {
      handleSelect(key,keyPath){
        this.cid= key
        this.$emit('indexSelect') //emit，即触发，在子组件中使用 $emit 方法，即可触发在父组件中定义的事件,indexSelect是自定义的
      }
    }
  }
</script>

<style scoped>
  .categories {
    position: fixed;
    margin-left: 45%;
    left: -580px;
    top: 100px;
    width: 150px;
  }
</style>


